<template>
    <div class="page-store-platform-store-present bg-content">
        <scroll-view scroll-x="true">
            <div class="table table-bordered" style="text-align: center; background: white; width: 800px;">
                <div class="tr">
                    <div class="td text-center bold" style="width: 120px;">操作</div>
                    <div class="td text-center bold" style="width: 120px;">编号</div>
                    <div class="td text-center bold" style="width: 120px;">寄件人</div>
                    <div class="td text-center bold" style="width: 120px;">联系电话</div>
                    <div class="td text-center bold" style="width: 250px;">寄件人地址</div>
                    <div class="td text-center bold" style="width: 120px;">显示顺序</div>
                </div>
                <div class="tr" v-for="(item, index)  in tbStoreSenderList" :key="item.id">
                    <div class="td text-center" style="width: 120px;">
                        <u-button type="error" size="mini" @click="select(item, index)">选择</u-button>
                    </div>
                    <div class="td text-center" style="width: 120px;">{{item.code}}</div>
                    <div class="td text-center" style="width: 120px;">{{item.name}}</div>
                    <div class="td text-center" style="width: 120px;">{{item.phone}}</div>
                    <div class="td text-center" style="width: 250px;">{{item.provinceName}}{{item.cityName}}{{item.areaName}}{{item.address}}</div>
                    <div class="td text-center" style="width: 120px;">{{item.displayOrder}}</div>
                </div>
            </div>
        </scroll-view>

        <div style="padding-top: 50px;" v-if="!tbStoreSenderList.length">
            <u-empty text="数据为空" mode="data"></u-empty>
        </div>

        <div style="padding-bottom: 60px;"></div>

        <div class="custom-bottom-button">
            <label @click="navigateTo('/pages/sub/sub2-store-platform/store-platform/store-platform-store-manage/store-platform-store-sender/store-platform-store-sender-add/index')">
                添加
            </label>
        </div>
    </div>
</template>

<script>

    import {TbStoreSenderService} from "@/dev/services/tb-store-sender.service";
    import {CommonUtil} from "@/dev/core/utils/common.util";

    export default {
        data() {
            return {
                tbStoreSenderList: []
            }
        },
        onShow() {
            this.findTbStoreSenderList();
        },
        methods: {
            select(item, index) {
                if (this.objParams.tbStoreSender !== undefined) {  // 添加了这个属性
                    this.objParams.tbStoreSender = item;
                }
                this.objParams.storeSenderId = item.id;
                this.objParams.storeSenderText = `${item.name},${item.phone},${item.provinceName}${item.cityName}${item.areaName}${item.address}`;
                CommonUtil.toastNavigateBack();
            },
            findTbStoreSenderList() {
                const _self = this;
                new TbStoreSenderService().findTbStoreSenderList({
                    storeId: _self.globalVariable.userInfo.tbStore.id,
                }).then(result => {
                    _self.tbStoreSenderList = result;
                });
            },
        }
    }
</script>
